home *** CD-ROM | disk | FTP | other *** search
- Path: news.mindlink.net!news
- From: genew@mindlink.bc.ca (Gene Wirchenko)
- Newsgroups: comp.lang.c
- Subject: Re: C constant expression declarations
- Date: Sat, 17 Feb 1996 02:02:25 GMT
- Organization: MIND LINK! - British Columbia, Canada
- Message-ID: <4g3d46$65h@fountain.mindlink.net>
- References: <31229735.41C67EA6@isi.com> <4fvl5cINN94q@keats.ugrad.cs.ubc.ca> <4g2nha$ksa@sun001.spd.dsccc.com>
- NNTP-Posting-Host: line161.nwm.mindlink.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- jmccarty@spd.dsccc.com (Mike McCarty) wrote:
-
- >In article <4fvl5cINN94q@keats.ugrad.cs.ubc.ca>,
- >Kazimir Kylheku <c2a192@ugrad.cs.ubc.ca> wrote:
- >)In article <31229735.41C67EA6@isi.com>, J.R. Stoner <jstoner@isi.com> wrote:
- >)>This is a query (I have checked the FAQ) into something that strikes me
- >)>as a dumbfoundedly stupid issue, but I will ask it anyway :)
- >)>
- >)>Normally, I will do things such as:
- >)>
- >)> #define EXPR1 1
- >)> #define EXPR2 2
- >)>
- >)>...and so on. Lately, I have been observing in code from other people
- >)>equivalent declarations such as:
- >)>
- >)> #define EXPR1 (1)
- >)> #define EXPR2 (2)
- >)
- >)This does not buy you anything at all, since the thing you are bracketing
- >)has only one constituent: it's not a compound expression.
-
- Just say that it's silly as is the lawyer-speak: four (4).
-
- >I respectfully disagree with this statement. It buys two very important
- >things, to wit:
-
- > it builds a good habit of putting parens in, so that when they
- > are needed they don't inadvertently get left out
-
- If they aren't needed, why is it a good habit? Would it not
- create bad habits by making programmers not bother to learn when
- parens are and aren't necessary?
-
- > it builds consistency, so that one gets a feeling that
- > "something may be wrong here" when inspecting code for
- > errors
-
- As in there are too many parens <G>?
-
- >I believe that (for the sake of creating and maintaining correct
- >programs) these are well worth the extra discipline (at first) and
- >compilation time for the cases where the parens are not strictly needed.
-
- Unfortunately, it can lead someone off into the tulies. I have
- heard
- return (0);
- explained as calling the return function. I think the extra
- discipline should be put into learning the syntax's associated
- semantics.
-
- >Mike
- >----
- >char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
-
- >I don't speak for DSC. <- They make me say that.
- ^
- I've always loved your sig. <snicker>
-
- Sincerely,
-
- Gene Wirchenko
-
- C Pronunciation Guide:
- y=x++; "wye equals ex plus plus semicolon"
- x=x++; "ex equals ex doublecross semicolon"
-
-